package service2;

import beans2.Patient;
import db2.PatientDao;
import db2.SignDao;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class SignService {
    public boolean UpdateRecord(String Account,int indid){//更新患者记录-患者完成就诊
        SignDao signDao=new SignDao();
        return signDao.UpSign(Account, indid);
    }
    public boolean UpdateRecordLate(String Account , int indid){//更新患者记录-患者过号
        SignDao signDao=new SignDao();
        System.out.println("UpdateRecordLate");
        return signDao.SignLate(Account,indid);
    }

    public int RecordSum(String DoctorID){//预约人数
        SignDao signDao=new SignDao();
        return signDao.SignSum(DoctorID);
    }
    public int RecordTreatSum(String DoctorID){//今日已完成就诊人数
        SignDao signDao=new SignDao();
        return signDao.SignTreatSum(DoctorID);
    }
    public boolean AddPatient(Patient patient,int schid){//添加患者
        SignDao signDao=new SignDao();
        return signDao.addSign(patient, schid);
    }
    public ArrayList<Patient> PatientALate(String DoctorID){//得到过号患者队列
        PatientDao patientDao=new PatientDao();
        ArrayList<Patient>list=patientDao.getallRecordLate(DoctorID);
        Collections.sort(list, new Comparator<Patient>() {
            @Override
            public int compare(Patient o1, Patient o2) {
                return o1.getOrder()- o2.getOrder();
            }
        });
        return list;
    }
}
